#include <stdio.h>
#include <string.h>
#define SIZE 8
char* getReal(char* raw);
char transform(char c);
void quickSort(char **realNumbers,int left, int right);
void printList(char **realNumbers,int size);
int main(){
	int size;
	scanf("%d",&size);
	char** realNumbers = new char*[size];
	for(int i=0;i<size;i++){
		char* input = new char[20];
		scanf("%s",input);
		realNumbers[i]=getReal(input);
	}
	quickSort(realNumbers,0,size-1);
	printList(realNumbers,size);
}

char* getReal(char* raw){
	char* temp=new char[9];
	int pos=0;
	for(int i=0;raw[i]!='\0';i++){
		char single=0;
		if(raw[i]>='0'&&raw[i]<='9'){
			single = raw[i];
		}else if(raw[i]>='A'&&raw[i]<='Y'&&raw[i]!='Q'){
			single = transform(raw[i]); 
		}
		if(single!=0){
			temp[pos]=single;
			pos++;
			if(pos==3)
				pos++;
		}
	}
	temp[3]='-';
	temp[8]='\0';
	return temp;
}

char transform(char c){
	if(c>='A'&&c<='P')
		return (c-'A')/3+2+'0';
	if(c>='R'&&c<='Y')
		return (c-'Q')/3+7+'0';
	return 0;
}

void quickSort(char *realNumbers[],int left, int right){
	if(left>=right)
		return;

	int pivot = left, tempLeft= left, tempRight= right;
	char* pivotNum = realNumbers[pivot];
	while(tempLeft<tempRight){

		while (tempLeft<tempRight&&memcmp(pivotNum,realNumbers[tempRight],SIZE)<=0)
			tempRight--;

		realNumbers[pivot]=realNumbers[tempRight];
		realNumbers[tempRight]=pivotNum;
		pivot = tempRight;

		while (tempLeft<tempRight&&memcmp(pivotNum,realNumbers[tempLeft],SIZE)>=0)
			tempLeft++;

		realNumbers[pivot]=realNumbers[tempLeft];
		realNumbers[tempLeft]=pivotNum;
		pivot = tempLeft;
	}
	quickSort(realNumbers,left,pivot-1);
	quickSort(realNumbers,pivot+1,right);
}

void printList(char **realNumbers,int size){
	bool printNone=true;
	char* current=realNumbers[0],quantity=1;
	for (int i=0;i<size-1;i++)
	{
		if (memcmp(realNumbers[i],realNumbers[i+1],SIZE)!=0)
		{
			if(quantity>1){
				printNone=false;
				printf("%s %d\n",current,quantity);
			}
			quantity=1;
			current=realNumbers[i+1];
		}else{
			quantity++;
		}
		if(i==size-2&&quantity>1){
			printNone=false;
			printf("%s %d\n",current,quantity);
		}
	}
	if(printNone)
		printf("No duplicates.\n");
}